package models.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import models.enumtype.MethodType;

@Entity
@Table(name = "MODULE_URI")
public class ModuleUri implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="MODULE_URI_ID_GENERATOR", sequenceName="MODULE_URI_SEQ",allocationSize = 1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MODULE_URI_ID_GENERATOR")
	@Column(name="MODULE_URI_ID")
	private Long uriId;

	@ManyToOne
	@JoinColumn(name="MODULE_ID")
	private Module module;

	@Column(name="URI")
	private String uri;

	@Column(name = "METHOD", columnDefinition = "string", nullable = false)
	@Type(type = "models.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "models.enumtype.MethodType"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	private MethodType method = MethodType.GET ;
	
	@Column(name="FUNCTION")
	private String function;
	
	@Column(name="IDX")
	private Integer idx = 0;

	public Long getUriId() {
		return uriId;
	}

	public void setUriId(Long uriId) {
		this.uriId = uriId;
	}

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public MethodType getMethod() {
		return method;
	}

	public void setMethod(MethodType method) {
		this.method = method;
	}

	public String getFunction() {
		return function;
	}

	public void setFunction(String function) {
		this.function = function;
	}

	public Integer getIdx() {
		return idx;
	}

	public void setIdx(Integer idx) {
		this.idx = idx;
	}
}